﻿using FastEventBus.Enum;
using FastEventBus.Exception;
using FastEventBus.Realization;
using FastIOC.Proxy;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastEventBus.Handle
{
    public class EventSessionFactory
    {
        public static EventSession OpenSession(EventHandlerStroageEnum StroageEnum)
        {
            EventSession Session = (EventSession)DynamictProxy.CreateProxyObject(typeof(EventSession), typeof(EventSession));
            switch (StroageEnum)
            {
                case EventHandlerStroageEnum.Memory:
                    Session.Stroage = new MemoryEventStroage();
                    break;
                case EventHandlerStroageEnum.Redis:
                    Session.Stroage = new RedisEventStroage();
                    break;
                case EventHandlerStroageEnum.MySQL:
                    throw new EventStroageNotImplException("MySQL方式事件消息存储还未实现！");
                    break;
                case EventHandlerStroageEnum.File:
                    throw new EventStroageNotImplException("File方式事件消息存储还未实现！");
                    break;
                default:
                    break;
            }
            return Session;
        }
    }
}
